/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-04 11:08:09
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-04 11:23:07
 * @Description: file content
 */

#include "apue.h"

#define BUF_SIZE 4096

int main()
{
    int n = 0;
    int writeLen = 0;
    char buf[BUF_SIZE] = {0};

    while (1)
    {
        n = read(STDIN_FILENO, buf, BUF_SIZE);
        if (n < 0)
        {
            err_sys("read error");
            break;
        }
        else if (0 == n)
        {
            break;
        }

        writeLen = write(STDOUT_FILENO, buf, n);
        if (writeLen != n)
        {
            err_sys("write error");
        }
    }

    exit(0);
}
